<?
require_once("class/config.php");

if(!isset($_POST['register']) || empty($_POST['register'])){
 print('<form action="" method="post">
		<center>
       <div class="login_text">Name:</div> <input type="text" name="name" class="login_box"><br>
       <div class="login_text">Password:</div> <input type="password" name="password" class="login_box"><br>
		<div class="login_text">Repeat your password:</div> <input type="password" name="password2" class="login_box"><br>
        <div class="login_text">E-Mail:</div> <input type="text" name="email" class="login_box"><br><br>
        <input type="submit" name="register" value="Register" class="login_button">
		</center>
        </form>');
}elseif($_POST['register'] == 'Register'){

$user = $_POST['name'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];

$date = date("Y-m-d G:i:s") ; 

$check = mysql_query("SELECT user FROM login WHERE user = '$user'") or die(mysql_error());  
$check_num = mysql_fetch_row($check);

$check_email = mysql_query("SELECT email FROM login WHERE email = '$email'") or die(mysql_error());
$check_email_n = mysql_fetch_row($check_email);
$hash = md5($password);

if($mail == "1");
if($password <> $password2){
print("<center>Your password is wrong!</center>");
print('<br><input type="button" value="Back" onClick="history.back();"></center>');
}elseif($check_num[0] == $user){
echo("<center>Username already in use!</center>");
print('<br><input type="button" value="Back" onClick="history.back();"></center>');
exit;
}elseif($check_email_n[0] == $email){
print("<center>E-mail already in use!</center>");
print('<br><input type="button" value="Back" onClick="history.back();"></center>');
exit;
}else{
if(!empty($password) && !empty($_POST['register'])){
mysql_query("INSERT INTO login (user, password, email, register_date) VALUES('$user', '$hash', '$email', '$date' ) ") or die(mysql_error()); 	
print("<center>Registration completet!</center><br>");
print(NOW());
}else{
print("<center>Registration not successfully</center>");
}
}
}
?>